package com.financing.wap.web.controller.api;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.financing.wap.common.Pager;
import com.financing.wap.common.ResultMap;
import com.financing.wap.dto.ProductNoticeDTO;
import com.financing.wap.service.IProductNoticeService;
import com.financing.wap.vo.ProductNoticeVO;
import com.financing.wap.web.controller.BaseController;

@Controller("productNoticeController")
@RequestMapping("/api/productNotice")
public class ProductNoticeController extends BaseController {

	@Autowired
	private IProductNoticeService productNoticeService;

	@RequestMapping("/queryProductNotice")
	@ResponseBody
	public ResultMap queryProductNotice(HttpServletRequest request, HttpServletResponse response, ProductNoticeVO notice, Pager pager) {
		ResultMap resultMap = new ResultMap();
		try {
			notice.setStart(pager.getStartIndex());
			List<ProductNoticeDTO> list = productNoticeService.queryProductNotice(notice);

			pager.setTotalCount(productNoticeService.queryProductNoticeCount(notice));
			
			resultMap.setAttribute("list", list);
			resultMap.setAttribute("pager", pager);
			resultMap.setStatus(ResultMap.STATUS.SUCCESS);
			resultMap.setStatusCode(ResultMap.STATUS_CODE_SUCCESS);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return resultMap;
	}
}
